//
// Created by Jisam on 2024年11月16日21:23:18.
// Solution of  C. Penchick and BBQ Buns
#include <bits/stdc++.h>

#define  int long long
#define  endl "\n"
#define  all(x) (x).begin(),(x).end()
#define  pb push_back
using namespace std;
// Solve the problem for n=2 and for even n in general.
// For odd n , there exists a color that appears at least thrice. What does this mean?
void solve(){
    int n;
    cin >> n;
    if(n % 2 == 0){
        for(int i = 1; i <= n ; i ++){
            cout << (i + 1) / 2 << " \n"[i == n];
        }
        return;
    }
    if(n >= 27){
        vector<int> a(n);
        a[0] = a[9] = a[25] = 1;
        a[26] = a[22] = 2;
        for(int i = 1; i <= 8; i++){
            a[i] = 3  + (i - 1) / 2;
        }for(int i = 10; i <= 21; i++){
            a[i] = 7  + (i - 10) / 2;
        }
        a[23] =a[24] = 13;
        for(int i = 27;i < n ; i ++){
            a[i] = (i + 1) / 2;
        }
        for(int i = 0 ; i < n ; i ++){
            cout << a[i] << " \n"[i == n - 1];
        }
        return ;
    }
    cout << "-1\n";
    return;
}
signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int _ = 1;
    cin >> _;
    while(_ --){
        solve();
    }
    return 0;
}